package cn.bxshey.activity.controller;

import cn.bxshey.activity.dto.AddActivityDTO;
import cn.bxshey.activity.service.ActivityService;
import cn.bxshey.general.Result.Result;
import cn.bxshey.general.aop.note.SystemLog;
import cn.bxshey.general.base.BaseController;
import cn.bxshey.general.entity.Activity;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @作者：不想说话而已
 * @Date：2024/2/1 10:42
 *
 */

/**
 * 活动服务
 */

@RestController
@RequestMapping("/activity")
public class ActivityController extends BaseController {

    @Resource
    ActivityService activityService;

    /**
     * 新增活动
     * @param addActivityDTO 活动信息
     * @return 是否成功
     */
    @PostMapping("/authentication/add")
    @SystemLog(value = "新增活动",serve = "1004")
    public Result<?> addActivity(@RequestBody AddActivityDTO addActivityDTO) {
        Long uid = Long.parseLong(String.valueOf(getUserLoginInfo().get("uid")));
        return Result.success( activityService.eventPosting(uid, addActivityDTO));
    }

    /**
     * 领取活动奖励优惠卷
     * @param activityId 活动唯一标识id
     * @return 优惠卷ID
     */
    @GetMapping("/attend/{activityId}")
    @SystemLog(value = "活动奖励领取",serve = "1004")
    public Result<String> attend(@PathVariable("activityId") String activityId){
        Long uid = Long.parseLong(String.valueOf(getUserLoginInfo().get("uid")));
        return Result.success( activityService.eventParticipation(uid,activityId));
    }





}
